package com.grass.appointment.model;

import android.content.Context;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.androidx.p013lv.base.bean.AttentionContentBean;
import com.androidx.p013lv.base.bean.UserInfo;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.JsonParams;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.utils.LogUtils;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.grass.appointment.bean.WordOfMouth;
import org.json.JSONObject;

public class UserPhoenixModel extends ViewModel {
    private MutableLiveData<BaseRes<String>> aboutHer;
    private MutableLiveData<Integer> actionLive;
    private MutableLiveData<BaseRes<UserInfo>> operationInfo;
    private MutableLiveData<BaseRes<String>> rewardHer;
    private MutableLiveData<BaseRes<WordOfMouth>> wordOfMouthLive;

    public MutableLiveData<BaseRes<WordOfMouth>> getWordOfMouthLive() {
        if (this.wordOfMouthLive == null) {
            this.wordOfMouthLive = new MutableLiveData<>();
        }
        return this.wordOfMouthLive;
    }

    public MutableLiveData<Integer> getAction() {
        if (this.actionLive == null) {
            this.actionLive = new MutableLiveData<>();
        }
        return this.actionLive;
    }

    public MutableLiveData<BaseRes<String>> rewardHer() {
        if (this.rewardHer == null) {
            this.rewardHer = new MutableLiveData<>();
        }
        return this.rewardHer;
    }

    public MutableLiveData<BaseRes<String>> dataAboutHer() {
        if (this.aboutHer == null) {
            this.aboutHer = new MutableLiveData<>();
        }
        return this.aboutHer;
    }

    public MutableLiveData<BaseRes<UserInfo>> operationInfo() {
        if (this.operationInfo == null) {
            this.operationInfo = new MutableLiveData<>();
        }
        return this.operationInfo;
    }

    public void getOperationInfo(Context context, int i) {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().operationUserInfo(i), new HttpCallback<BaseRes<UserInfo>>("operationUserInfo", context) {
            /* class com.grass.appointment.model.UserPhoenixModel.C28541 */

            public void onLvSuccess(BaseRes<UserInfo> baseRes) {
                UserPhoenixModel.this.operationInfo.setValue(baseRes);
            }
        });
    }

    public void isFollowUser(int i, boolean z) {
        if (i == SpUtils.getInstance().getUserInfo().getUserId()) {
            ToastUtils.getInstance().showSigh("不能關註自己");
            return;
        }
        String str = "followUser";
        HttpUtils.getInsatance().cancelTag(str);
        HttpUtils.getInsatance().cancelTag("cancelFollow");
        UrlManager insatance = UrlManager.getInsatance();
        String followUser = z ? insatance.followUser() : insatance.cancelFollowUser();
        JSONObject commit = JsonParams.build().add("beenUserId", Integer.valueOf(i)).commit();
        HttpUtils insatance2 = HttpUtils.getInsatance();
        if (!z) {
            str = "cancelFollow";
        }
        insatance2.post(followUser, commit, new HttpCallback<BaseRes<AttentionContentBean>>(str) {
            /* class com.grass.appointment.model.UserPhoenixModel.C28552 */

            public void onLvSuccess(BaseRes<AttentionContentBean> baseRes) {
                LogUtils.m63e("----->", baseRes.toString());
            }
        });
    }

    public void meetLock(Context context, int i) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().meetLock(), JsonParams.build().add("toUserId", Integer.valueOf(i)).commit(), new HttpCallback<BaseRes<String>>("meetLock", context) {
            /* class com.grass.appointment.model.UserPhoenixModel.C28563 */

            public void onLvSuccess(BaseRes<String> baseRes) {
                UserPhoenixModel.this.aboutHer.setValue(baseRes);
            }
        });
    }

    public void rewardNow(Context context, int i, int i2, String str) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().reward(), JsonParams.build().add(Key.USER_ID, Integer.valueOf(i)).add("gold", Integer.valueOf(i2)).add("remark", str).commit(), new HttpCallback<BaseRes<String>>("reward", context) {
            /* class com.grass.appointment.model.UserPhoenixModel.C28574 */

            public void onLvSuccess(BaseRes<String> baseRes) {
                UserPhoenixModel.this.rewardHer.setValue(baseRes);
            }
        });
    }

    public void setAction() {
        this.actionLive.setValue(Integer.valueOf((int) Key.ACTION_OK));
    }

    public void setWordOfMouthLive(int i, String str) {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().getWordOfMouth(i, str), new HttpCallback<BaseRes<WordOfMouth>>("getWordOfMouth") {
            /* class com.grass.appointment.model.UserPhoenixModel.C28585 */

            public void onLvSuccess(BaseRes<WordOfMouth> baseRes) {
                UserPhoenixModel.this.wordOfMouthLive.setValue(baseRes);
            }
        });
    }

    public void cancelHttp() {
        HttpUtils.getInsatance().cancelTag("operationUserInfo");
        HttpUtils.getInsatance().cancelTag("followUser");
        HttpUtils.getInsatance().cancelTag("cancelFollow");
        HttpUtils.getInsatance().cancelTag("meetLock");
        HttpUtils.getInsatance().cancelTag("reward");
        HttpUtils.getInsatance().cancelTag("getWordOfMouth");
    }
}
